package org.jacky.javafx.pagination;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class PaginationTest extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        PaginationComponent pagination = new PaginationComponent();
        pagination.setTotalSize(30);
        pagination.setPageSize(10);
        pagination.setPageBtnCount(9);
        pagination.setCurrentPage(2);
        pagination.setPaginationButtonFontSize(12);

        pagination.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent actionEvent) {
                System.out.println("当前选择的页码:" + pagination.getCurrentPage());
            }
        });

        final VBox vb = new VBox();
        vb.setPrefHeight(200);
        vb.setPrefWidth(200);
        vb.setStyle("-fx-padding: 50px 0px 0px 0px;");
        vb.getChildren().add(pagination);

        Scene scene = new Scene(vb);
        primaryStage.setScene(scene);
        primaryStage.sizeToScene();
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
